import React from "react";
import ReanimatedSwipeable from "react-native-gesture-handler/ReanimatedSwipeable";

interface SwipeableProps {
  children: React.ReactNode;
  overshootLeft?: boolean;
  overshootRight?: boolean;
  friction?: number;
  rightThreshold?: number;
  leftThreshold?: number;
  renderRightActions?: (progress: any, dragX: any) => React.ReactNode;
}

export default function Swipeable({
  children,
  overshootLeft = false,
  overshootRight = false,
  friction = 2,
  rightThreshold = 0,
  leftThreshold = 1000,
  renderRightActions = () => null,
}: SwipeableProps) {
  return (
    <ReanimatedSwipeable
      overshootLeft={overshootLeft}
      overshootRight={overshootRight}
      enableTrackpadTwoFingerGesture
      friction={friction} // 增加摩擦力使得滑动更难
      rightThreshold={rightThreshold}
      leftThreshold={leftThreshold} // 或设置极大的阈值
      renderRightActions={renderRightActions}
    >
      {children}
    </ReanimatedSwipeable>
  );
}
